(function() {
  window.validate_idno = function(id_no, label) {
    var coefficients, cv, i, sum , v, _i, _len;
    if (id_no.length !== 18) {
      return {
        succ: false,
        errmsg: "" + label + "身份证号码长度" + id_no.length + "不等于18."
      };
    }
    coefficients = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10,  5,  8, 4,  2];
    cv = '10X98765432';
    sum  =  0;
    for (i = _i = 0, _len = coefficients.length; _i < _len; i = ++_i) {
      v = coefficients[i];
      sum += v * id_no[i];
    }
    if (cv[sum  %  11] === id_no[17]) {
      return {
        succ: true
      };
    }
    return {
      succ: false,
      errmsg: "" + label + "身份证号码校验失败."
    };
  };

  window.validate_cardno = function(card_no, label) {
    var i, reverse_no, sum, v, _i, _ref;
    reverse_no = card_no.split('').reverse().join('');
    sum = 0;
    for (i = _i = 0, _ref = reverse_no.length - 1; 0 <= _ref ? _i <= _ref : _i >= _ref; i = 0 <= _ref ? ++_i : --_i) {
      v = parseInt(reverse_no.charAt(i));
      if (i % 2 === 1) {
        v *= 2;
        if (v >= 10) {
          v -= 9;
        }
      }
      sum += v;
    }
    if (sum % 10 === 0) {
      return true;
    }
  };

  window.freeze_form = function(form) {
    form.find('a').hide();
    form.find('.dropdown').not('.nofreeze').addClass('disabled').css('opacity', '0.9').find('input').attr('readonly', 'readonly');
    form.find('.input').not('.nofreeze').addClass('disabled').css('opacity', '0.9').find('input').attr('readonly', 'readonly');
    form.find('textarea').not('.nofreeze').attr('readonly', 'readonly');
    return form.find('.ui.checkbox').css('opacity', '0.9');
  };

  window.trctl_fields = ["time_begin", "time_end", "min_amt_per", "max_amt_per", "min_amt_per2", "max_amt_per2", "max_amt_minute", "max_cnt_minute", "max_amt_day", "max_cnt_day"];

}).call(this);
